﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class InboundDetailDA : IInboundDetailDA
    {
        private string CASE_CNT = "@CASE_CNT";
        private string CREATED_BY = "@CREATED_BY";
        private string CUBE = "@CUBE";
        private string EXPIRY_DATE = "@EXPIRY_DATE";
        private string EXTERNAL_LOT = "@EXTERNAL_LOT";
        private string FROM_LOC = "@FROM_LOC";
        private string FROM_LPN_ID = "@FROM_LPN_ID";
        private string GROSS_WGT = "@GROSS_WGT";
        private string HOLD_CODE = "@HOLD_CODE";
        private string INNER_PACK = "@INNER_PACK";
        private string LOT = "@LOT";
        private string LOT_ATTR01 = "@LOT_ATTR01";
        private string LOT_ATTR02 = "@LOT_ATTR02";
        private string LOT_ATTR03 = "@LOT_ATTR03";
        private string LOT_ATTR04 = "@LOT_ATTR04";
        private string LOT_ATTR05 = "@LOT_ATTR05";
        private string LOT_ATTR06 = "@LOT_ATTR06";
        private string LOT_ATTR07 = "@LOT_ATTR07";
        private string LOT_ATTR08 = "@LOT_ATTR08";
        private string LOT_ATTR09 = "@LOT_ATTR09";
        private string LOT_ATTR10 = "@LOT_ATTR10";
        private string NET_WGT = "@NET_WGT";
        private string OTHER_UNIT1 = "@OTHER_UNIT1";
        private string OTHER_UNIT2 = "@OTHER_UNIT2";
        private string OWNER_ID = "@OWNER_ID";
        private string PACK_ID = "@PACK_ID";
        private string PALLET = "@PALLET";
        private string PRODUCE_DATE = "@PRODUCE_DATE";
        private string QTY = "@QTY";
        private string RECEIPT_DATE = "@RECEIPT_DATE";
        private string RECEIPT_ID = "@RECEIPT_ID";
        private string RECEIPT_LINE_ID = "@RECEIPT_LINE_ID";
        private string SKU_ID = "@SKU_ID";
        private string SOURCE_TRANS_ID = "@SOURCE_TRANS_ID";
        private string SOURCE_TRANS_TYPE = "@SOURCE_TRANS_TYPE";
        private string SQL_CHECK_INBOUND_DETAIL_ID_UNIQUE = " SELECT COUNT(1) FROM @_@INV_TRANS WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID AND TRANS_ID = @TRANS_ID ";
        private string SQL_DELETE_INBOUND_DETAIL = " DELETE FROM @_@INV_TRANS WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID ";
        private string SQL_DELETE_ONE_INBOUND_DETAIL = " DELETE FROM @_@INV_TRANS WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID AND TRANS_ID = @TRANS_ID ";
        private string SQL_INSERT_INBOUND_DETAIL = " INSERT INTO @_@INV_TRANS ( WH_ID, TRANS_ID, TRANS_TYPE, OWNER_ID, SKU_ID, LOT, FROM_LOC, FROM_LPN_ID, TO_LOC, TO_LPN_ID, SOURCE_TRANS_ID, SOURCE_TRANS_TYPE, STATUS, LOT_ATTR01, LOT_ATTR02, LOT_ATTR03, LOT_ATTR04, LOT_ATTR05, LOT_ATTR06, LOT_ATTR07, LOT_ATTR08, LOT_ATTR09, LOT_ATTR10, PRODUCE_DATE, EXPIRY_DATE, RECEIPT_DATE, EXTERNAL_LOT, QTY, CASE_CNT, INNER_PACK, PALLET, CUBE, GROSS_WGT, NET_WGT, OTHER_UNIT1, OTHER_UNIT2, PACK_ID, UOM_ID, UOM_CALC, UOM_QTY, RECEIPT_ID, RECEIPT_LINE_ID, HOLD_CODE, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @TRANS_ID, @TRANS_TYPE, @OWNER_ID, @SKU_ID, @LOT, @FROM_LOC, @FROM_LPN_ID, @TO_LOC, @TO_LPN_ID, @SOURCE_TRANS_ID, @SOURCE_TRANS_TYPE, @STATUS, @LOT_ATTR01, @LOT_ATTR02, @LOT_ATTR03, @LOT_ATTR04, @LOT_ATTR05, @LOT_ATTR06, @LOT_ATTR07, @LOT_ATTR08, @LOT_ATTR09, @LOT_ATTR10, @PRODUCE_DATE, @EXPIRY_DATE, @RECEIPT_DATE, @EXTERNAL_LOT, @QTY, @CASE_CNT, @INNER_PACK, @PALLET, @CUBE, @GROSS_WGT, @NET_WGT, @OTHER_UNIT1, @OTHER_UNIT2, @PACK_ID, @UOM_ID, @UOM_CALC, @UOM_QTY, @RECEIPT_ID, @RECEIPT_LINE_ID, @HOLD_CODE, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_INBOUND_DETAIL = " SELECT  ROWID, WH_ID, TRANS_ID, TRANS_TYPE, OWNER_ID, SKU_ID, LOT, FROM_LOC, FROM_LPN_ID, TO_LOC, TO_LPN_ID, SOURCE_TRANS_ID, SOURCE_TRANS_TYPE, STATUS, LOT_ATTR01, LOT_ATTR02, LOT_ATTR03, LOT_ATTR04, LOT_ATTR05, LOT_ATTR06, LOT_ATTR07, LOT_ATTR08, LOT_ATTR09, LOT_ATTR10, PRODUCE_DATE, EXPIRY_DATE, RECEIPT_DATE, EXTERNAL_LOT, QTY, CASE_CNT, INNER_PACK, PALLET, CUBE, GROSS_WGT, NET_WGT, OTHER_UNIT1, OTHER_UNIT2, PACK_ID, UOM_ID, UOM_CALC, UOM_QTY, RECEIPT_ID, RECEIPT_LINE_ID, HOLD_CODE, TS, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@INV_TRANS ";
        private string SQL_UPDATE_INBOUND_DETAIL = " UPDATE @_@INV_TRANS SET WH_ID = @WH_ID, TRANS_TYPE = @TRANS_TYPE, OWNER_ID = @OWNER_ID, SKU_ID = @SKU_ID, LOT = @LOT, FROM_LOC = @FROM_LOC, FROM_LPN_ID = @FROM_LPN_ID, TO_LOC = @TO_LOC, TO_LPN_ID = @TO_LPN_ID, SOURCE_TRANS_ID = @SOURCE_TRANS_ID, SOURCE_TRANS_TYPE = @SOURCE_TRANS_TYPE, STATUS = @STATUS, LOT_ATTR01 = @LOT_ATTR01, LOT_ATTR02 = @LOT_ATTR02, LOT_ATTR03 = @LOT_ATTR03, LOT_ATTR04 = @LOT_ATTR04, LOT_ATTR05 = @LOT_ATTR05, LOT_ATTR06 = @LOT_ATTR06, LOT_ATTR07 = @LOT_ATTR07, LOT_ATTR08 = @LOT_ATTR08, LOT_ATTR09 = @LOT_ATTR09, LOT_ATTR10 = @LOT_ATTR10, PRODUCE_DATE = @PRODUCE_DATE, EXPIRY_DATE = @EXPIRY_DATE, RECEIPT_DATE = @RECEIPT_DATE, EXTERNAL_LOT = @EXTERNAL_LOT, QTY = @QTY, CASE_CNT = @CASE_CNT, INNER_PACK = @INNER_PACK, PALLET = @PALLET, CUBE = @CUBE, GROSS_WGT = @GROSS_WGT, NET_WGT = @NET_WGT, OTHER_UNIT1 = @OTHER_UNIT1, OTHER_UNIT2 = @OTHER_UNIT2, PACK_ID = @PACK_ID, UOM_ID = @UOM_ID, UOM_CALC = @UOM_CALC, UOM_QTY = @UOM_QTY, RECEIPT_ID = @RECEIPT_ID, RECEIPT_LINE_ID = @RECEIPT_LINE_ID, HOLD_CODE = @HOLD_CODE, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID AND TRANS_ID = @TRANS_ID  ";
        private string STATUS = "@STATUS";
        private string TO_LOC = "@TO_LOC";
        private string TO_LPN_ID = "@TO_LPN_ID";
        private string TRANS_ID = "@TRANS_ID";
        private string TRANS_TYPE = "@TRANS_TYPE";
        private string TS = "@TS";
        private string UOM_CALC = "@UOM_CALC";
        private string UOM_ID = "@UOM_ID";
        private string UOM_QTY = "@UOM_QTY";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public bool CheckInboundDetailIDUnique(string receiptID, string receiptLineID, string transID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID), new SqlParameter("@TRANS_ID", transID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_INBOUND_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckInboundDetailIDUnique(DataBase dataBase, DbTransaction tran, string receiptID, string receiptLineID, string transID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID), new SqlParameter("@TRANS_ID", transID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_INBOUND_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteInboundDetail(List<string> receiptID, List<string> receiptLineID, List<string> whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < receiptID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID[j]), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteInboundDetail(List<string> receiptID, List<string> receiptLineID, List<string> transID, List<string> whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < receiptID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID[j]), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID[j]), new SqlParameter("@TRANS_ID", transID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_ONE_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteInboundDetail(DataBase dataBase, DbTransaction tran, List<string> receiptID, List<string> receiptLineID, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < receiptID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID[j]), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteInboundDetail(DataBase dataBase, DbTransaction tran, List<string> receiptID, List<string> receiptLineID, List<string> transID, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < receiptID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID[j]), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID[j]), new SqlParameter("@TRANS_ID", transID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_ONE_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllInboundDetail(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllInboundDetail(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public InboundDetailInfo GetInboundDetailByID(string receiptID, string receiptLineID, string transID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID) + " WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID AND TRANS_ID = @TRANS_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID), new SqlParameter("@TRANS_ID", transID) };
            InboundDetailInfo inboundDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    DateTime CS00003;
                    inboundDetailInfo = new InboundDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRANS_ID"].ToString(), reader["TRANS_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOT"].ToString(), reader["FROM_LOC"].ToString(), reader["FROM_LPN_ID"].ToString(), reader["TO_LOC"].ToString(), reader["TO_LPN_ID"].ToString(), reader["SOURCE_TRANS_ID"].ToString(), reader["SOURCE_TRANS_TYPE"].ToString(), reader["STATUS"].ToString(), reader["LOT_ATTR01"].ToString(), reader["LOT_ATTR02"].ToString(), reader["LOT_ATTR03"].ToString(), reader["LOT_ATTR04"].ToString(), reader["LOT_ATTR05"].ToString(), reader["LOT_ATTR06"].ToString(), reader["LOT_ATTR07"].ToString(), reader["LOT_ATTR08"].ToString(), reader["LOT_ATTR09"].ToString(), reader["LOT_ATTR10"].ToString(), (reader["PRODUCE_DATE"].ToString() != "") ? DateTime.Parse(reader["PRODUCE_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["EXPIRY_DATE"].ToString() != "") ? DateTime.Parse(reader["EXPIRY_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["RECEIPT_DATE"].ToString() != "") ? DateTime.Parse(reader["RECEIPT_DATE"].ToString()) : (CS00003 = new DateTime()), reader["EXTERNAL_LOT"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["PACK_ID"].ToString(), reader["UOM_ID"].ToString(), (reader["UOM_CALC"].ToString() != "") ? int.Parse(reader["UOM_CALC"].ToString()) : 0, (reader["UOM_QTY"].ToString() != "") ? decimal.Parse(reader["UOM_QTY"].ToString()) : 0M, reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["HOLD_CODE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return inboundDetailInfo;
        }

        public InboundDetailInfo GetInboundDetailByID(DataBase dataBase, DbTransaction tran, string receiptID, string receiptLineID, string transID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID) + " WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID AND TRANS_ID = @TRANS_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID), new SqlParameter("@TRANS_ID", transID) };
            InboundDetailInfo inboundDetailInfo = null;
            using (IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    DateTime CS00003;
                    inboundDetailInfo = new InboundDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRANS_ID"].ToString(), reader["TRANS_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOT"].ToString(), reader["FROM_LOC"].ToString(), reader["FROM_LPN_ID"].ToString(), reader["TO_LOC"].ToString(), reader["TO_LPN_ID"].ToString(), reader["SOURCE_TRANS_ID"].ToString(), reader["SOURCE_TRANS_TYPE"].ToString(), reader["STATUS"].ToString(), reader["LOT_ATTR01"].ToString(), reader["LOT_ATTR02"].ToString(), reader["LOT_ATTR03"].ToString(), reader["LOT_ATTR04"].ToString(), reader["LOT_ATTR05"].ToString(), reader["LOT_ATTR06"].ToString(), reader["LOT_ATTR07"].ToString(), reader["LOT_ATTR08"].ToString(), reader["LOT_ATTR09"].ToString(), reader["LOT_ATTR10"].ToString(), (reader["PRODUCE_DATE"].ToString() != "") ? DateTime.Parse(reader["PRODUCE_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["EXPIRY_DATE"].ToString() != "") ? DateTime.Parse(reader["EXPIRY_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["RECEIPT_DATE"].ToString() != "") ? DateTime.Parse(reader["RECEIPT_DATE"].ToString()) : (CS00003 = new DateTime()), reader["EXTERNAL_LOT"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["PACK_ID"].ToString(), reader["UOM_ID"].ToString(), (reader["UOM_CALC"].ToString() != "") ? int.Parse(reader["UOM_CALC"].ToString()) : 0, (reader["UOM_QTY"].ToString() != "") ? decimal.Parse(reader["UOM_QTY"].ToString()) : 0M, reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["HOLD_CODE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return inboundDetailInfo;
        }

        public DataSet GetInboundDetailByQueryList(List<string> sqlWhere, InboundDetailQueryEntity inbounddetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!inbounddetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, inbounddetailQuery.CurrentPage, inbounddetailQuery.PageSize, inbounddetailQuery.SortField, inbounddetailQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetInboundDetailByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, InboundDetailQueryEntity inbounddetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!inbounddetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, inbounddetailQuery.CurrentPage, inbounddetailQuery.PageSize, inbounddetailQuery.SortField, inbounddetailQuery.SortDirection);
            }
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public List<InboundDetailInfo> GetInboundDetailListByID(string receiptID, string receiptLineID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID) + " WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID) };
            List<InboundDetailInfo> inboundDetailInfos = new List<InboundDetailInfo>();
            InboundDetailInfo inboundDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    inboundDetailInfo = new InboundDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRANS_ID"].ToString(), reader["TRANS_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOT"].ToString(), reader["FROM_LOC"].ToString(), reader["FROM_LPN_ID"].ToString(), reader["TO_LOC"].ToString(), reader["TO_LPN_ID"].ToString(), reader["SOURCE_TRANS_ID"].ToString(), reader["SOURCE_TRANS_TYPE"].ToString(), reader["STATUS"].ToString(), reader["LOT_ATTR01"].ToString(), reader["LOT_ATTR02"].ToString(), reader["LOT_ATTR03"].ToString(), reader["LOT_ATTR04"].ToString(), reader["LOT_ATTR05"].ToString(), reader["LOT_ATTR06"].ToString(), reader["LOT_ATTR07"].ToString(), reader["LOT_ATTR08"].ToString(), reader["LOT_ATTR09"].ToString(), reader["LOT_ATTR10"].ToString(), (reader["PRODUCE_DATE"].ToString() != "") ? DateTime.Parse(reader["PRODUCE_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["EXPIRY_DATE"].ToString() != "") ? DateTime.Parse(reader["EXPIRY_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["RECEIPT_DATE"].ToString() != "") ? DateTime.Parse(reader["RECEIPT_DATE"].ToString()) : (CS00002 = new DateTime()), reader["EXTERNAL_LOT"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["PACK_ID"].ToString(), reader["UOM_ID"].ToString(), (reader["UOM_CALC"].ToString() != "") ? int.Parse(reader["UOM_CALC"].ToString()) : 0, (reader["UOM_QTY"].ToString() != "") ? decimal.Parse(reader["UOM_QTY"].ToString()) : 0M, reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["HOLD_CODE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                    inboundDetailInfos.Add(inboundDetailInfo);
                }
            }
            return inboundDetailInfos;
        }

        public List<InboundDetailInfo> GetInboundDetailListByID(DataBase dataBase, DbTransaction tran, string receiptID, string receiptLineID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_INBOUND_DETAIL.Replace("@_@", whLoginID) + " WHERE RECEIPT_ID = @RECEIPT_ID AND RECEIPT_LINE_ID = @RECEIPT_LINE_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECEIPT_ID", receiptID), new SqlParameter("@RECEIPT_LINE_ID", receiptLineID) };
            List<InboundDetailInfo> inboundDetailInfos = new List<InboundDetailInfo>();
            InboundDetailInfo inboundDetailInfo = null;
            using (IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    inboundDetailInfo = new InboundDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRANS_ID"].ToString(), reader["TRANS_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOT"].ToString(), reader["FROM_LOC"].ToString(), reader["FROM_LPN_ID"].ToString(), reader["TO_LOC"].ToString(), reader["TO_LPN_ID"].ToString(), reader["SOURCE_TRANS_ID"].ToString(), reader["SOURCE_TRANS_TYPE"].ToString(), reader["STATUS"].ToString(), reader["LOT_ATTR01"].ToString(), reader["LOT_ATTR02"].ToString(), reader["LOT_ATTR03"].ToString(), reader["LOT_ATTR04"].ToString(), reader["LOT_ATTR05"].ToString(), reader["LOT_ATTR06"].ToString(), reader["LOT_ATTR07"].ToString(), reader["LOT_ATTR08"].ToString(), reader["LOT_ATTR09"].ToString(), reader["LOT_ATTR10"].ToString(), (reader["PRODUCE_DATE"].ToString() != "") ? DateTime.Parse(reader["PRODUCE_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["EXPIRY_DATE"].ToString() != "") ? DateTime.Parse(reader["EXPIRY_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["RECEIPT_DATE"].ToString() != "") ? DateTime.Parse(reader["RECEIPT_DATE"].ToString()) : (CS00002 = new DateTime()), reader["EXTERNAL_LOT"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["PACK_ID"].ToString(), reader["UOM_ID"].ToString(), (reader["UOM_CALC"].ToString() != "") ? int.Parse(reader["UOM_CALC"].ToString()) : 0, (reader["UOM_QTY"].ToString() != "") ? decimal.Parse(reader["UOM_QTY"].ToString()) : 0M, reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["HOLD_CODE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                    inboundDetailInfos.Add(inboundDetailInfo);
                }
            }
            return inboundDetailInfos;
        }

        public int InsertInboundDetail(InboundDetailInfo inboundDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    inboundDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_InboundDetail_Parameters(inboundDetailInfo);
                    if (paras != null)
                    {
                        result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int InsertInboundDetail(DataBase dataBase, DbTransaction tran, InboundDetailInfo inboundDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    inboundDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_InboundDetail_Parameters(inboundDetailInfo);
                    if (paras != null)
                    {
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_INBOUND_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_InboundDetail_Parameters(InboundDetailInfo inboundDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.TRANS_ID, SqlDbType.VarChar, 20), new SqlParameter(this.TRANS_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.OWNER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.SKU_ID, SqlDbType.VarChar, 50), new SqlParameter(this.LOT, SqlDbType.VarChar, 20), new SqlParameter(this.FROM_LOC, SqlDbType.VarChar, 20), new SqlParameter(this.FROM_LPN_ID, SqlDbType.VarChar, 20), new SqlParameter(this.TO_LOC, SqlDbType.VarChar, 20), new SqlParameter(this.TO_LPN_ID, SqlDbType.VarChar, 20), new SqlParameter(this.SOURCE_TRANS_ID, SqlDbType.VarChar, 20), new SqlParameter(this.SOURCE_TRANS_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.STATUS, SqlDbType.VarChar, 20), new SqlParameter(this.LOT_ATTR01, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR02, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR03, SqlDbType.VarChar, 50), 
                new SqlParameter(this.LOT_ATTR04, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR05, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR06, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR07, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR08, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR09, SqlDbType.VarChar, 50), new SqlParameter(this.LOT_ATTR10, SqlDbType.VarChar, 50), new SqlParameter(this.PRODUCE_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.EXPIRY_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.RECEIPT_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.EXTERNAL_LOT, SqlDbType.VarChar, 100), new SqlParameter(this.QTY, SqlDbType.Decimal, 13), new SqlParameter(this.CASE_CNT, SqlDbType.Decimal, 13), new SqlParameter(this.INNER_PACK, SqlDbType.Decimal, 13), new SqlParameter(this.PALLET, SqlDbType.Decimal, 13), new SqlParameter(this.CUBE, SqlDbType.Float, 8), 
                new SqlParameter(this.GROSS_WGT, SqlDbType.Float, 8), new SqlParameter(this.NET_WGT, SqlDbType.Float, 8), new SqlParameter(this.OTHER_UNIT1, SqlDbType.Float, 8), new SqlParameter(this.OTHER_UNIT2, SqlDbType.Float, 8), new SqlParameter(this.PACK_ID, SqlDbType.VarChar, 50), new SqlParameter(this.UOM_ID, SqlDbType.VarChar, 20), new SqlParameter(this.UOM_CALC, SqlDbType.Int, 4), new SqlParameter(this.UOM_QTY, SqlDbType.Decimal, 13), new SqlParameter(this.RECEIPT_ID, SqlDbType.VarChar, 20), new SqlParameter(this.RECEIPT_LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.HOLD_CODE, SqlDbType.VarChar, 20), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(inboundDetailInfo.WhID))
            {
                paramArray[0].Value = inboundDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = inboundDetailInfo.TransID;
            paramArray[2].Value = inboundDetailInfo.TransType;
            paramArray[3].Value = inboundDetailInfo.OwnerID;
            paramArray[4].Value = inboundDetailInfo.SkuID;
            paramArray[5].Value = inboundDetailInfo.Lot;
            paramArray[6].Value = inboundDetailInfo.FromLoc;
            paramArray[7].Value = inboundDetailInfo.FromLpnID;
            paramArray[8].Value = inboundDetailInfo.ToLoc;
            paramArray[9].Value = inboundDetailInfo.ToLpnID;
            if (!string.IsNullOrEmpty(inboundDetailInfo.SourceTransID))
            {
                paramArray[10].Value = inboundDetailInfo.SourceTransID;
            }
            else
            {
                paramArray[10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(inboundDetailInfo.SourceTransType))
            {
                paramArray[11].Value = inboundDetailInfo.SourceTransType;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(inboundDetailInfo.Status))
            {
                paramArray[12].Value = inboundDetailInfo.Status;
            }
            else
            {
                paramArray[12].Value = DBNull.Value;
            }
            paramArray[13].Value = inboundDetailInfo.LotAttr01;
            paramArray[14].Value = inboundDetailInfo.LotAttr02;
            paramArray[15].Value = inboundDetailInfo.LotAttr03;
            if (!string.IsNullOrEmpty(inboundDetailInfo.LotAttr04))
            {
                paramArray[0x10].Value = inboundDetailInfo.LotAttr04;
            }
            else
            {
                paramArray[0x10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(inboundDetailInfo.LotAttr05))
            {
                paramArray[0x11].Value = inboundDetailInfo.LotAttr05;
            }
            else
            {
                paramArray[0x11].Value = DBNull.Value;
            }
            paramArray[0x12].Value = inboundDetailInfo.LotAttr06;
            paramArray[0x13].Value = inboundDetailInfo.LotAttr07;
            paramArray[20].Value = inboundDetailInfo.LotAttr08;
            paramArray[0x15].Value = inboundDetailInfo.LotAttr09;
            paramArray[0x16].Value = inboundDetailInfo.LotAttr10;
            DateTime CS00003 = new DateTime();
            if (inboundDetailInfo.ProduceDate != CS00003)
            {
                paramArray[0x17].Value = inboundDetailInfo.ProduceDate;
            }
            else
            {
                paramArray[0x17].Value = DBNull.Value;
            }
            if (inboundDetailInfo.ExpiryDate != new DateTime())
            {
                paramArray[0x18].Value = inboundDetailInfo.ExpiryDate;
            }
            else
            {
                paramArray[0x18].Value = DBNull.Value;
            }
            paramArray[0x19].Value = inboundDetailInfo.ReceiptDate;
            if (!string.IsNullOrEmpty(inboundDetailInfo.ExternalLot))
            {
                paramArray[0x1a].Value = inboundDetailInfo.ExternalLot;
            }
            else
            {
                paramArray[0x1a].Value = DBNull.Value;
            }
            paramArray[0x1b].Value = inboundDetailInfo.Qty;
            paramArray[0x1c].Value = inboundDetailInfo.CaseCnt;
            paramArray[0x1d].Value = inboundDetailInfo.InnerPack;
            paramArray[30].Value = inboundDetailInfo.Pallet;
            paramArray[0x1f].Value = inboundDetailInfo.Cube;
            paramArray[0x20].Value = inboundDetailInfo.GrossWgt;
            paramArray[0x21].Value = inboundDetailInfo.NetWgt;
            paramArray[0x22].Value = inboundDetailInfo.OtherUnit1;
            paramArray[0x23].Value = inboundDetailInfo.OtherUnit2;
            if (!string.IsNullOrEmpty(inboundDetailInfo.PackID))
            {
                paramArray[0x24].Value = inboundDetailInfo.PackID;
            }
            else
            {
                paramArray[0x24].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(inboundDetailInfo.UomID))
            {
                paramArray[0x25].Value = inboundDetailInfo.UomID;
            }
            else
            {
                paramArray[0x25].Value = DBNull.Value;
            }
            paramArray[0x26].Value = inboundDetailInfo.UomCalc;
            paramArray[0x27].Value = inboundDetailInfo.UomQty;
            if (!string.IsNullOrEmpty(inboundDetailInfo.ReceiptID))
            {
                paramArray[40].Value = inboundDetailInfo.ReceiptID;
            }
            else
            {
                paramArray[40].Value = DBNull.Value;
            }
            paramArray[0x29].Value = inboundDetailInfo.ReceiptLineID;
            if (!string.IsNullOrEmpty(inboundDetailInfo.HoldCode))
            {
                paramArray[0x2a].Value = inboundDetailInfo.HoldCode;
            }
            else
            {
                paramArray[0x2a].Value = DBNull.Value;
            }
            paramArray[0x2b].Value = inboundDetailInfo.CreatedBy;
            paramArray[0x2c].Value = inboundDetailInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateInboundDetail(InboundDetailInfo inboundDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                inboundDetailInfo.WhID = whLoginID[0].Substring(0, whLoginID[0].Length - 1);
                SqlParameter[] paras = this.Set_InboundDetail_Parameters(inboundDetailInfo);
                if (paras != null)
                {
                    result += DBHelper.ExecuteNonQuery(CommandType.Text, this.SQL_UPDATE_INBOUND_DETAIL.Replace("@_@", whLoginID[0]), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateInboundDetail(DataBase dataBase, DbTransaction tran, InboundDetailInfo inboundDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                inboundDetailInfo.WhID = whLoginID[0].Substring(0, whLoginID[0].Length - 1);
                SqlParameter[] paras = this.Set_InboundDetail_Parameters(inboundDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_INBOUND_DETAIL.Replace("@_@", whLoginID[0]), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

